import { resetRouter, routes } from "@/router";
import { defineStore } from "pinia";
import { ref } from "vue";
import { type RouteRecordRaw } from "vue-router";

const useMenuStore = defineStore('zhihuiyuanqu-menu', () => {
  // 菜单路由列表
  const menuList = ref<RouteRecordRaw[]>([...routes])
  // 设置菜单路由列表
  const setMenuList = (newMenuList: RouteRecordRaw[]) => {
    menuList.value = [...menuList.value, ...newMenuList]
  }
  // 重置路由列表
  const clearMenuList = ()=>{
    // 重置左侧菜单
    menuList.value = [...routes]
    // 重置路由系统
    resetRouter()
  }

  return {
    menuList,
    setMenuList,
    clearMenuList
  }
})

export {
  useMenuStore
}